package cz.idsv.web.mvc.model.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

/**
 * PersonType Entity.
 * 
 * @author Jan Borzensky
 */

@Entity(name = "PersonType")
@Table(name = "PERSONTYPE")
public class PersonTypeEntity implements Serializable {

	private static final long serialVersionUID = -8712872333957386182L;

	private Integer id = null;
	private String role = null;
	/**
	 * Gets id (primary key).
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Integer getId() {
		return id;
	}

	/**
	 * Sets id (primary key).
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * Gets type.
	 */
	public String getrole() {
		return role;
	}

	/**
	 * Sets type.
	 */
	@Column(name = "ROLE")
	public void setRole(String role) {
		this.role = role;
	}
	
	/**
	 * Returns a string representation of the object.
	 */
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();

		sb.append(this.getClass().getName() + "-");
		sb.append("  id=" + id);
		sb.append("  role=" + role);
		
		return sb.toString();
	}

	/**
	 * Returns a hash code value for the object.
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;

		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((role == null) ? 0 : role.hashCode());
		
		result = prime * result
				+ ((id == null) ? 0 : id.hashCode());
		result = prime * result
				+ ((role == null) ? 0 : role.hashCode());
		
		return result;
	}

	/**
	 * Indicates whether some other object is equal to this one.
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		final PersonTypeEntity other = (PersonTypeEntity) obj;

		if (id == null) {
			if (other.id != null) {
				return false;
			}
		} else if (!id.equals(other.id)) {
			return false;
		}
		
		if (role == null) {
			if (other.role != null) {
				return false;
			}
		} else if (!role.equals(other.role)) {
			return false;
		}
		
		return true;
	}

}
